package com.demon.example.service;

import com.demon.example.mapper.UserMapper;
import com.demon.example.model.entity.UserPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public UserPO getById(Long id) {
        return userMapper.selectByPrimaryKey(id);
    }

    public UserPO getByPhone(String phone) {
        Example example = new Example(UserPO.class);
        example.createCriteria()
                .andEqualTo("phone", phone);
        return userMapper.selectOneByExample(example);
    }
}
